var express = require('express');
var router = express.Router();
var body = {};
var check = require('./check');
var checkLogin = check['checkLogin'];
var checkNotLogin = check['checkNotLogin'];

router.get('/',checkNotLogin);
router.get('/',function(req,res,next){
    res.render('admin',{});
});
router.post('/',checkNotLogin);
router.post('/',function(req,res,next){
    console.log(req.body);
    body = req.body;
    var name = body.name;
    var password = body.password;
    console.log(name+"   "+password);
    if(name==='admin'&&password==='ZhWy197531'){
        console.log('success');
        req.session.user = "admin";
        res.json({"message":"登录成功","success":true});
    }else{
        console.log('fail');
        res.json({"message":"请输入正确用户名和密码！","success":false});
    }
});
module.exports = router;